package  com.pcbly.web.business.publicinfo;

/**
* @author carl.song
* Copyright (c) 2010 Lightsoft, International.
* All rights reserved.
*
*/

import java.util.HashMap;
import java.util.List;

import com.pcbly.web.persistence.publicinfo.MobileSetDao;
import com.pcbly.web.persistence.table.ColumnDao;
import com.pcbly.web.bean.publicinfo.MobileSetBean;
import com.pcbly.web.bean.table.ColumnBean;
import com.pcbly.web.business.BaseServiceImp;
import com.pcbly.web.components.hibernate.support.Page;
import com.pcbly.web.components.form.AbstractAnalyseCommonDataExt;
import com.pcbly.web.components.form.AnalyseCommonDataExtCreate;
import com.pcbly.web.components.form.AnalyseCommonDataExtEdit;
import com.pcbly.web.components.form.AnalyseCommonDataExtView;

 
public class MobileSetServiceImp extends BaseServiceImp<MobileSetBean> implements MobileSetService {
	 public MobileSetServiceImp() {
		super();
		// TODO Auto-generated constructor stub
	}
	private MobileSetDao mobileSetDao;
	
	private ColumnDao columnDao;

	public void setColumnDao(ColumnDao columnDao) {
		this.columnDao = columnDao;
	}
	
	public void setMobileSetDao(MobileSetDao mobileSetDao) {
		this.mobileSetDao = mobileSetDao;
	}
	
	@Override
	public MobileSetBean getMobileSetBeanById(String id) throws Exception {
		// TODO Auto-generated method stub
		return mobileSetDao.get(MobileSetBean.class,id);
	}
	
	@Override
	public void removeMobileSetBeanById(String id) throws Exception{
		mobileSetDao.removeMobileSetBeanById(id);
	}
	
	@Override
	public void removeMobileSetBeanByIds(String ids) throws Exception{
		mobileSetDao.removeMobileSetBeanByIds(ids);
	}
	
	
	@Override
	public MobileSetBean saveMobileSetBean(MobileSetBean publicinfo) throws Exception{
		return mobileSetDao.saveMobileSetBean(publicinfo);
	}
	
	@Override
	public MobileSetBean updateMobileSetBean(MobileSetBean publicinfo) throws Exception{
		mobileSetDao.saveObject( publicinfo);
		return publicinfo;
	}
	public Page<MobileSetBean>  findMobileSetBeanByCond(MobileSetBean bean,
			Page<MobileSetBean> page, String orderByName, boolean asc)
			throws Exception{
		return mobileSetDao.findMobileSetBeanByCond(
				bean, page, orderByName, asc);
	}
	
	@Override
	public String findMobileSetBeanExtCreate(String tableName) throws Exception {
		// TODO Auto-generated method stub
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtCreate();
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findMobileSetBeanExtEdit(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = mobileSetDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtEdit();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findMobileSetBeanExtView(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = mobileSetDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtView();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public void saveMobileSetBeanExt(String sql) throws Exception {
		// TODO Auto-generated method stub
		mobileSetDao.saveCommnonDataBeanExt(sql);
	}

	@Override
	public boolean getHasMobileSetBeanExtData(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		return mobileSetDao.getHasCommnonDataBeanExt(tableName, id);
	}
}
